package day03;
// 算数运算符
public class OperDemo01 {
    public static void main(String[] args) {
        //1) 算数运算符: +, -, *, /, %, ++, --
        /*
        System.out.println(5%2); //1, 商2余1
        System.out.println(2%5); //2, 商0余2
        System.out.println(8%2); //0, 商4余0----整除
        System.out.println(0%5); //0, 商0余0----整除
        注: 0取余任何数都是整除
        */
        //2) ++/-- 自增和自减
        //++ 未被使用时的情况: a++和++a的值都为a+1
        /*
        第一遍:
        int a = 5, b = 5;
        a++; //相当于a=a+1
        b++; //相当于b=b+1
        System.out.println(a);//6
        System.out.println(b);//6

        //++ 被使用时的情况: a++的值为a, ++a的值为a+1
        int c = 5, d = 5;
        int e = c++;//将c++的值5赋给e, 同时c自增1变为6
        int f = ++d;//将++d的值6赋给f, 同时d自增1变为6
        System.out.println(c);//6
        System.out.println(d);//6
        System.out.println(e);//5
        System.out.println(f);//6
        ------------------------------------------
        第二遍:
        int a = 5, b = 5;
        a++; //相当于a=a+1
        ++b; //相当于b=b+1
        System.out.println(a);//6
        System.out.println(b);//6

        int c = 5, d = 5;
        int e = c++;
        int f = ++d;
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
        System.out.println(f);
        */



        // --的单独使用
        /*
        第一遍:
        int a = 5, b = 5;
        a--;
        --b;
        System.out.println(a);
        System.out.println(b);

        int c = 5, d = 5;
        int e = c--;
        int f = --d;
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
        System.out.println(f);
        ---------------------------------
        第二遍
        int a = 5, b = = 5;
        a--;
        --b;
        System.out.println(a);
        System.out.println(b);

        int c = 5, d = 5;
        int e = c--;
        int f = --d;
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
        System.out.println(f);
        */


    }
}
